﻿#pragma once
#define LK_WINDOWS_UI_BUTTON_
namespace LK
{
	namespace Windows
	{
		namespace UI
		{
			/**
			@brief 表示一个按钮控件*/
			class IButton :public IControl
			{
			public:
				IButton(const IButton&) { Throw <ptr<NotSupportException> >(); }
				BMETHODS(PButton,IButton)
				//默认的按钮过程处理函数指针
				static LONG_PTR pfun;
				IButton(HWND hParent)
					:IControl()
				{
					SetHandle(Create(L"Button", Rect(0, 0, 160, 60), L"BUTTON", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 0, hParent, NULL));

					pfun = GetWindowLongPtrW(GetHandle(), GWL_WNDPROC);
					if (pfun == 0)Throw<PException >(GetLastError());
					if (SetWindowLongPtrW(GetHandle(), GWL_WNDPROC, (LONG_PTR)&StaticWndProc) == 0)Throw<PException >(GetLastError());
				}

				/*重写默认消息处理*/
				virtual LRESULT DefWndProc(MSG& message);

				//重写消息循环（可重写）
				virtual void WndProc(MSG& ){}
			};
			/**
			@brief 按钮控件的代理*/
			class PButton :public PControl
			{
			public:
				PMETHODS(PButton, IButton);
				//从父控件进行构造
				PButton(PControl const &c) :PControl(new IButton(c.Check()->GetHandle())){}

			};
		}
	}
}
